Module modLoop
    Public ExitLoop As Boolean = False

    Public Sub StartLoop()
        'Show the main form so we can see it.
        'frmMain.Show()
        'frmMain.Focus()

        Do
            'If Windowed = True Then
            Application.DoEvents()
            'End If

            'Check to see if the window is active.
            CheckFocused()


            'Update everythng.
            Update()

            RenderGame()


            'Clear the screen.
            TV.Clear()

            'Render the 2d stuff.
            Render2D()

            'Render everything to the screen.
            TV.RenderToScreen()

        Loop Until ExitLoop

        'Exit the program
        End
    End Sub

    Public Sub RenderLoading()
        TV.Clear()
        ScrText.Action_BeginText()
        ScrText.NormalFont_DrawText("Loading...", 380, 290, GrgbA(0.7, 1))
        ScrText.Action_EndText()
        TV.RenderToScreen()
    End Sub

    Private Sub CheckFocused()
        'If the window is active then.
        If frmMain.Focused = True Then
            'Check the input.
            CheckInput()
        End If
    End Sub

End Module
